<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="attachementDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='attachementDetail.heading'/>"/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="attachementList.attachement"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<div class="span2">
    <h2><fmt:message key="attachementDetail.heading"/></h2>
    <fmt:message key="attachementDetail.message"/>
</div>

<div class="span7">
    <s:form id="attachementForm" action="saveAttachement" method="post" validate="true" cssClass="well form-horizontal"   enctype="multipart/form-data">
        <s:hidden key="attachement.id"/>
    	<c:if test="${not empty attachement.id}">
        <s:textfield key="attachement.filename" required="true" maxlength="100" />
        </c:if>
    	<c:if test="${not empty attachement.id}">
    	<fieldset class="control-group">
    	<label class="control-label">  </label>
    	<div class="controls">
    			<a href="attachmentdownload?attachmentid=<c:out value="${attachement.id}"/>" >Download this file</a>
    	</div>
		</fieldset>
		 </c:if>
		 <c:if test="${empty attachement.id}">
		 <s:file label="Add attachment" name="attachmentfile"/>
		 </c:if>
        <s:select name="attachement.notice.id" list="noticeList" listKey="id" listValue="title"  label="Notice"></s:select>
		<c:if test="${not empty attachement.id}">
    	<fieldset class="control-group">
    	<label class="control-label">  </label>
    	<div class="controls">
    			<a href="editNotice?id=<c:out value="${attachement.notice.id}"/>">View Notice</a>
    	</div>
		</fieldset>
		 </c:if>
		 
        <div id="actions" class="form-actions">
            <s:submit type="button" cssClass="btn btn-primary" method="save" key="button.save" theme="simple">
                <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
            </s:submit>
            <c:if test="${not empty attachement.id}">
                <s:submit type="button" cssClass="btn btn-warning" method="delete" key="button.delete"
                    onclick="return confirmMessage(msgDelConfirm)" theme="simple">
                    <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                </s:submit>
            </c:if>
            <s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
                <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
            </s:submit>
        </div>
    </s:form>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['attachementForm']).focus();
    });
</script>
